home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / sc3x04.exe / GETOBDSK.C < prev    next >
Text File  |  1992-09-03  |  5KB  |  116 lines

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      getobdsk.c                                            ║
  4. //   ║ abstract:    This module shows how to make 3.x system calls using  ║
  5. //   ║              the F2 Shell Interface.  Obviously, it requires the   ║
  6. //   ║              NetWare Shell.                                        ║
  7. //   ║                                                                    ║
  8. //   ║ environment: NetWare 3.x v3.11                                     ║
  9. //   ║              Borland C 3.0                                         ║
  10. //   ║                                                                    ║
  11. //   ║  This software is provided as is and carries no warranty           ║
  12. //   ║  whatsoever.  Novell disclaims and excludes any and all implied    ║
  13. //   ║  warranties of merchantability, title and fitness for a particular ║
  14. //   ║  purpose.  Novell does not warrant that the software will satisfy  ║
  15. //   ║  your requirements or that the software is without defect or error ║
  16. //   ║  or that operation of the software will be uninterrupted.  You are ║
  17. //   ║  using the software at your risk.  The software is not a product   ║
  18. //   ║  of Novell, Inc. or any of subsidiaries.                           ║
  19. //   ╚════════════════════════════════════════════════════════════════════╝
  20. //
  21. //                         ****** N O T I C E ******
  22. //    
  23. //     This software is considered pre-release and may be used at your own
  24. //     risk and has been provided due to the many requests of our cust-
  25. //     omers. 
  26. //
  27.  
  28. #include <stdio.h>
  29. #include <string.h>
  30. #include <stdlib.h>
  31. #include <dos.h>
  32.  
  33. #include "nwsys.h"
  34.  
  35. //
  36. //  First of all, we define the request and reply structures which are
  37. //  needed for the GetBinderyObjectID API call.  These structures
  38. //  are layed out according to the System Call documentation.
  39. //
  40.  
  41. struct  {
  42.     WORD    sflen;          // length of the structure 
  43.     BYTE    sfcode;         // the subfunction code
  44.     WORD    otype;          // object type (hi-lo)
  45.     BYTE    onlen;          // length of name (below)
  46.     BYTE    oname[48];      // name 
  47. }GETOBJRequest;
  48.  
  49. struct  {
  50.     LONG    oid;            // the object ID returned (hi-lo)
  51.     WORD    otype;          // the object type returned (hi-lo)
  52.     BYTE    oname[48];      // the object name returned (ASCIIZ)
  53. }GETOBJReply;
  54.  
  55. //  First of all, we define the request and reply structures which are
  56. //  needed for the GetObjectDiskUsageAndRestriction API call.  These
  57. //  structures are layed out according to the System Call documentation.
  58. //
  59.  
  60. struct  {
  61.     WORD    sflen;          // length of the structure
  62.     BYTE    sfcode;         // the subfunction code
  63.     BYTE    volumeNumber;   // volume number
  64.     LONG    oid;            // object for which information is to be returned
  65. }GETOBDSKRequest;
  66.  
  67. struct  {
  68.     LONG    restriction;    //  Restriction on object for specified volume
  69.     LONG    inUse;          //  Actual space in use by object
  70. }GETOBDSKReply;
  71.  
  72. //
  73. //  This is the main program.  The purpose is to make the GetObjectDisk
  74. //  Restriction API call to illustrate making system calls using the
  75. //  F2 interface.
  76. //
  77.  
  78. void main(int argc, char *argv[])
  79. {
  80.     int     cc;
  81.     int     length;
  82.  
  83.     if(argc!=4){printf("usage: GETOBDSK objectName ObjectType VolumeNumber\n");exit(1);}
  84. //
  85. //  Build the request buffer
  86. //
  87.    GETOBJRequest.sfcode = 53;                        // subfunction code
  88.    GETOBJRequest.otype  = WordSwap(atoi(argv[2]));   // object type
  89.    GETOBJRequest.onlen  = strlen(argv[1]);           // object name length
  90.    GETOBJRequest.sflen  = WordSwap(6+GETOBJRequest.onlen);
  91.                                                      // length of this request
  92.    strcpy(GETOBJRequest.oname,argv[1]);              // object name
  93.  
  94.    cc = NWSystemCall(23,&GETOBJRequest,sizeof GETOBJRequest,&GETOBJReply,sizeof GETOBJReply);
  95.  
  96.    printf("Function returned:    %03d--%#02x\n",cc,cc);
  97.    if( cc == 0 ){
  98.        printf("Object id returned:   %#010lx\n",DWordSwap(GETOBJReply.oid));
  99.        printf("Object type returned: %#06x\n",WordSwap(GETOBJReply.otype));
  100.        printf("Object name returned: %s\n",GETOBJReply.oname);
  101.    }
  102. //
  103. //  Build the request buffer for the restriction call
  104. //
  105.    GETOBDSKRequest.sflen = sizeof GETOBDSKRequest;
  106.    GETOBDSKRequest.sfcode = 41;                       // subfunction code
  107.    GETOBDSKRequest.volumeNumber=atoi(argv[3]);
  108.    GETOBDSKRequest.oid=GETOBJReply.oid;
  109.    cc = NWSystemCall(22,&GETOBDSKRequest,sizeof GETOBDSKRequest,&GETOBDSKReply,sizeof GETOBDSKReply);
  110.    printf("Function returned:    %03d--%#02x\n",cc,cc);
  111.    if( cc == 0 ) {
  112.        printf("Restriction:          %8ld\n",GETOBDSKReply.restriction);
  113.        printf("In Use:                 %8ld\n",GETOBDSKReply.inUse);
  114.    }
  115. }
  116.